<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<div style="text-align: center;">
			<select name="">
				<option value="">请对本次色子大小下注</option>
				<option id='bigimg' value="大">大</option>
				<option id="bigimg" value="小">小</option>
			</select><br />
			<img id="imgs" src="img1/1.jpg" height="100px" width="100px"><br />
			
			<button type="button" onclick="DoAction();" >开始</button>
		</div>
	</body>
	<script type="text/javascript">
		function DoAction(){
			var num =0;
			var bigimg =document.getElementById('bigimg');
			
			
			var img =document.getElementById('imgs');
			var arr =["img1/1.jpg","img1/2.jpg","img1/3.jpg","img1/4.jpg","img1/5.jpg","img1/6.jpg"]
			var i =1;
			
			var setIntervals = setInterval(function(){	
				img.src =arr[i];
				i++;
				if(i>arr.length){
					i=0;
					img.src =arr[i];
					i++;
					
					var randoms =get();
					console.log(randoms);
					
					switch(bigimg.value){
						case "大":
						if(randoms>=4 && randoms<=6){
							alert('你押大');
							break;
						}else{
							alert('中小了,您赔钱了')
						}
							break;
						case "小":
						if(randoms>=1 && randoms<=3){
							alert('你押小');
							break;
						}else{
							alert('中大了,您赔钱了')
						}
					}
					num++;
					 if(num>0){
					 	clearInterval(setIntervals);
					 }				
				}
				
			},50)
			
		}
		function get(){
		while(true){
			var randoms = Math.floor(Math.random()*10);
			if(randoms !=0 && randoms !=7 && randoms!=8 && randoms!=9){
				return randoms;
			}
			}
		}
	</script>
</html>
